<template>
  <div class="list">
    <!-- 轮播图 -->
    <van-swipe :autoplay="3000">
      <van-swipe-item v-for="(image, index) in swiperList" :key="index">
        <img v-lazy="image.picUrl" />
      </van-swipe-item>
    </van-swipe>
    <!-- 商品分类 categoryItemList -->
    <div class="categoryListBox">
      <div
        class="categoryBox"
        v-for="(item, index) in categoryItemList"
        :key="index"
      >
        <h2>{{ item.category.name }}</h2>
        <div class="subtitle">{{ item.category.frontName }}</div>
        <div class="content">
          <div class="itemBox" v-for="(img, i) in item.itemList" :key="i">
            <a class="goodsBox" href="">
              <img class="goodsImg" v-lazy="img.listPicUrl" alt="" />
            </a>
            <div class="descBox">
              <h3>{{ img.name }}</h3>
              <div class="priceBox">
                <div class="theBox">
                  <span
                    class="price priceAcitve"
                    v-if="img.counterPrice > img.retailPrice"
                    >￥{{ img.counterPrice }}</span
                  >
                  <span
                    class="price"
                    :class="
                      img.counterPrice < img.retailPrice
                        ? 'priceAcitve'
                        : 'delPrice'
                    "
                    >￥{{ img.retailPrice }}</span
                  >
                </div>
                <span class="itemTagList" v-if="img.itemTagList.length">
                  {{ img.itemTagList[0].name }}
                </span>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <!--  -->
  </div>
</template>

<script>
export default {
  name: "HomeList",
  props: ["data"],
  data() {
    return {};
  },
  computed: {
    swiperList() {
      return this.data.data.currentCategory.bannerList;
    },
    categoryItemList() {
      return this.data.data.categoryItemList;
    },
    isSkeleton() {
      return !this.data;
    },
  },
  created() {
    console.log(this.data);
  },
};
</script>

<style lang="less">
.list {
  background: #eeeeee;
  .van-swipe {
    background: #fff;
    padding-top: 2rem;
    height: 4rem;
    margin-bottom: 0.25rem;
    .van-swipe__track {
      .van-swipe-item {
        position: relative;
        img {
          position: absolute;
          width: 100%;
          top: -50%;
          transform: translateY(30%);
        }
      }
    }
    .van-swipe__indicators {
      bottom: 0.4rem;
      .van-swipe__indicator {
        width: 0.6rem;
        height: 0.06rem;
        border-radius: 0;
        &.van-swipe__indicator--active {
          background: #fff;
        }
      }
    }
  }
  .categoryListBox {
    .categoryBox {
      background: #fff;
      margin-bottom: 0.25rem;
      padding: 0.3rem;
      h2 {
        width: 5rem;
        font-size: 0.42rem;
        font-weight: normal;
        margin: auto;
        text-align: center;
        height: 0.7rem;
        line-height: 0.7rem;
      }
      .subtitle {
        width: 5rem;
        font-size: 0.22rem;
        font-weight: normal;
        margin: auto;
        text-align: center;
        height: 0.7rem;
        color: #aaa;
      }
      .content {
        display: flex;
        flex-wrap: wrap;
        justify-content: space-between;
        background: #fff;
        .itemBox {
          width: 4.55rem;
          padding-bottom: 0.5rem;
          .goodsBox {
            .goodsImg {
              width: 100%;
            }
          }
          .descBox {
            h3 {
              font-size: 0.38rem;
              font-weight: 400;
            }
            .priceBox {
              .theBox {
                padding-bottom: 0.1rem;
                .price {
                  &.priceAcitve {
                    color: #dd1a21;
                    font-size: 0.4rem;
                  }
                  &.delPrice {
                    text-decoration: line-through;
                  }
                }
              }
              .itemTagList {
                box-sizing: border-box;
                padding: 0 0.1rem;
                color: #dd1a21;
                border: 1px solid #dd1a21;
                height: 0.3rem;
                line-height: 0.3rem;
                border-radius: 0.3rem;
                margin-top: 0.3rem;
              }
            }
          }
        }
      }
    }
  }
}
</style>